package pprg;

import java.io.BufferedReader;
import java.io.InputStreamReader;

class Util {

	public static int readIntInput(String infoMsg, String errorMsg) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Boolean error = false;
		String input = "";
		int value = 0;
		do {
			System.out.print(infoMsg);
			try {
				input = br.readLine();
				value = Integer.parseInt(input);
				error = false;
			} catch (Exception e) {
				error = true;
				System.err.println(errorMsg);
			}
		} while (error == true);
		return value;
	}

	public static double readDoubleInput(String infoMsg, String errorMsg) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Boolean error = false;
		String input = "";
		double value = 0.0;
		do {
			System.out.print(infoMsg);
			try {
				input = br.readLine();
				value = Double.parseDouble(input);
				error = false;
			} catch (Exception e) {
				error = true;
				System.err.println(errorMsg);
			}
		} while (error == true);
		return value;
	}
}
